{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from forceFieldInfo import *\n",
    "# 从pdb文件读取原子类型和连接，构建id-atomtype list\n",
    "atomType = []\n",
    "connect = []\n",
    "with open('../sam2.pdb', 'r') as f:\n",
    "    for line in f:\n",
    "        if(line.startswith('HETATM')):\n",
    "            t = list(filter(lambda x: x, line.split(' ')))\n",
    "            atomType.append(t[2])\n",
    "        elif(line.startswith('CONECT')):\n",
    "            t = list(filter(lambda x: x, line.split(' ')))\n",
    "            connect.append(t[1:-1:])\n",
    "atomTypeStr = []\n",
    "for con in connect:\n",
    "    head = atomType[int(con[0])-1]\n",
    "    restList = [atomType[int(x)-1] for x in con[1::]]\n",
    "    restList.sort()\n",
    "    str1 = head + '_'+''.join(restList)\n",
    "    atomTypeStr.append(str1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#读取坐标和 partial charge信息(h2o.chg)\n",
    "idx = 0\n",
    "atomInfo = []\n",
    "with open('../h2o.chg', 'r') as f:\n",
    "    for line in f.readlines():\n",
    "        t = list(filter(lambda x: x, line.split(' ')))\n",
    "        if t[0] != atomType[idx]:\n",
    "            print('wrong atom type')\n",
    "        t[-1] = '%f' % (float(t[-1])*1.2)\n",
    "        atomInfo.append(t)\n",
    "        idx += 1\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
